<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var queryString = function (s, n) {
      while (n > 0) {
        if (s.indexOf(n.toString(2)) == -1) return false;
        n--;
      }
      return true;
    };
    console.log(queryString('0010', 2))
  </script>
</body>

</html>